package flc.ast.adapter;

import android.view.View;
import android.widget.ImageView;

import androidx.annotation.NonNull;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;

import flc.ast.R;
import stark.common.basic.adaptermutil.StkProviderMultiAdapter;
import stark.common.bean.StkResBean;

public class PizzaAdapter extends StkProviderMultiAdapter<StkResBean> {
    public PizzaAdapter() {
        super(8);
        addItemProvider(new PizzaItemProvider());
    }

    private class PizzaItemProvider extends BaseItemProvider<StkResBean> {
        @Override
        public int getItemViewType() {
            return StkProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_pizza;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, StkResBean bean) {
           if (bean.isSelected()){
               Glide.with(baseViewHolder.itemView).load(bean.getThumbUrl()).into((ImageView) baseViewHolder.getView(R.id.ivPizzaItemImg));
               baseViewHolder.getView(R.id.rlPizzaItemSel).setVisibility(View.VISIBLE);
               baseViewHolder.getView(R.id.rlPizzaItemNormal).setVisibility(View.INVISIBLE);
           }else {
               Glide.with(baseViewHolder.itemView).load(bean.getThumbUrl()).into((ImageView) baseViewHolder.getView(R.id.ivPizzaItemNormal));
               baseViewHolder.getView(R.id.rlPizzaItemSel).setVisibility(View.INVISIBLE);
               baseViewHolder.getView(R.id.rlPizzaItemNormal).setVisibility(View.VISIBLE);
           }
        }
    }
}
